package im.redis.collection;

import im.redis.client.JedisTemplate;

import com.alibaba.fastjson.JSON;

public class RedisCollections {

	private JedisTemplate jedisTemplate;

	public RedisCollections(JedisTemplate jedisTemplate) {
		super();
		this.jedisTemplate = jedisTemplate;
	}

	protected String serialize(Object o) {
		return JSON.toJSONString(o);
	}

	protected <E> E deserialize(String json, Class<E> clazz) {
		return JSON.parseObject(json, clazz);
	}

	protected JedisTemplate getJedisTemplate() {
		return jedisTemplate;
	}

	public <E> RSortedSet<E> getSortedSet(Class<E> clazz, String name) {
		return new RSortedSet<>(this, name, clazz);
	}

	public <E> RDelayQueue<E> getDelayQueue(Class<E> clazz, String name) {
		return new RDelayQueue<E>(this, name, clazz);
	}
}
